let currentServCategId = 0;
/**
 * zmn平台业务类型
 * 文件命名格式：zmn.模块.表/功能.js
 * @author linfeng
 * @since 2020/09/04 18:06
 */
layui.define(['index', 'form', 'layedit', 'table', 'laydate','element'], function (exports) {
    var $ = layui.$;
    var form = layui.form;
    var layer = layui.layer;
    var laydate = layui.laydate;
    var element = layui.element;
    var table = layui.table;

    form.render(null, "zmn-form");

    table.init('zmn-table', {
        limit: json.items.length,
        page: false
    });

    // 提交
    form.on('submit(zmn-form-submit)', function(obj){
        var data = new Array();

        for (let i = 10; i < 50; i = i + 10) {
            let inputName = "bizType" + i;
            let bizType = $('input[name=' + inputName + ']');
            let bizTypeArray = new Array();
            for(let k in bizType){
                if(bizType[k].checked)
                    bizTypeArray.push(bizType[k].value);
            }

            if (bizTypeArray.length > 0) {
               let bizTypeStr = bizTypeArray.join(",");
               let innerObject = new Object();
               innerObject['plat'] = i;
               innerObject['bizTypeStr'] = bizTypeStr;
               data.push(innerObject);
            } else {
                parent.layui.layer.msg("每个平台至少开通一个业务类型",{"icon":2});
                return false;
            }
        }

        var openId = layer.open({type: 3});

        var url = "/plat/biztype/addEdit.action";

        $.ajax({
            async: false,
            type: "POST", url: url,
            contentType: "application/json", dataType: "json", data: JSON.stringify(data),
            success:function(resp) {
                layer.close(openId);
                var message = resp.status == 200 ? "操作成功！" : resp.message;
                if(resp.status == 200) {
                    zmnPage.reload(message, 1000);
                } else {
                    layer.open({
                        title: '温馨提示'
                        ,content: message
                    });
                }
            },
            error:function(XMLHttpRequest, textStatus, errorThrown){
                layer.close(openId);
            }
        })
        return false;
    });


    //对外暴露的接口
    exports('plat_biztype_detail', {});
});